package com.bootdo.china.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.bootdo.china.dao.ChinaDataDao;
import com.bootdo.china.domain.ChinaData;
import com.bootdo.china.service.ChinaDataService;



@Service
public class ChinaDataServiceImpl implements ChinaDataService {
	@Autowired
	private ChinaDataDao chinaDataDao;
	
	@Override
	public ChinaData get(Long id){
		return chinaDataDao.get(id);
	}
	
	@Override
	public List<ChinaData> list(Map<String, Object> map){
		return chinaDataDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return chinaDataDao.count(map);
	}
	
	@Override
	public int save(ChinaData chinaData){
	
		if(chinaData.getId() != null) {
			int r = chinaDataDao.update(chinaData);
			if(r <= 0){
				return  chinaDataDao.save(chinaData);
			}else{
				return r;
			}
		}else {
			return chinaDataDao.save(chinaData);
		}		
	
		
	}
	
	@Override
	public int update(ChinaData chinaData){
		return chinaDataDao.update(chinaData);
	}
	
	@Override
	public int remove(Long id){
		return chinaDataDao.remove(id);
	}
	
	@Override
	public int batchRemove(Long[] ids){
		return chinaDataDao.batchRemove(ids);
	}

	public ChinaDataDao getChinaDataDao() {
		return chinaDataDao;
	}

	public void setChinaDataDao(ChinaDataDao chinaDataDao) {
		this.chinaDataDao = chinaDataDao;
	}
}
